package com.dindang.checkline.mvp.greendao.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.dindang.checkline.mvp.greendao.entity.CheckPiont.Level_Converter;
import java.util.List;

import com.dindang.checkline.mvp.greendao.entity.CheckPiont;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "CHECK_PIONT".
*/
public class CheckPiontDao extends AbstractDao<CheckPiont, Long> {

    public static final String TABLENAME = "CHECK_PIONT";

    /**
     * Properties of entity CheckPiont.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property LBuilding = new Property(1, int.class, "lBuilding", false, "L_BUILDING");
        public final static Property CNo = new Property(2, String.class, "cNo", false, "C_NO");
        public final static Property LId = new Property(3, Long.class, "lId", false, "L_ID");
        public final static Property CName = new Property(4, String.class, "cName", false, "C_NAME");
        public final static Property CDesc = new Property(5, String.class, "cDesc", false, "C_DESC");
        public final static Property CQrcode = new Property(6, String.class, "cQrcode", false, "C_QRCODE");
        public final static Property DCreate = new Property(7, String.class, "dCreate", false, "D_CREATE");
        public final static Property CStatus = new Property(8, String.class, "cStatus", false, "C_STATUS");
        public final static Property CPosition = new Property(9, String.class, "cPosition", false, "C_POSITION");
        public final static Property UserId = new Property(10, String.class, "userId", false, "USER_ID");
        public final static Property LineId = new Property(11, Long.class, "lineId", false, "LINE_ID");
        public final static Property IsFinshPoint = new Property(12, String.class, "isFinshPoint", false, "IS_FINSH_POINT");
        public final static Property RItemLastTime = new Property(13, String.class, "rItemLastTime", false, "R_ITEM_LAST_TIME");
        public final static Property Info = new Property(14, String.class, "info", false, "INFO");
    }

    private final Level_Converter infoConverter = new Level_Converter();

    public CheckPiontDao(DaoConfig config) {
        super(config);
    }
    
    public CheckPiontDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"CHECK_PIONT\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"L_BUILDING\" INTEGER NOT NULL ," + // 1: lBuilding
                "\"C_NO\" TEXT," + // 2: cNo
                "\"L_ID\" INTEGER," + // 3: lId
                "\"C_NAME\" TEXT," + // 4: cName
                "\"C_DESC\" TEXT," + // 5: cDesc
                "\"C_QRCODE\" TEXT," + // 6: cQrcode
                "\"D_CREATE\" TEXT," + // 7: dCreate
                "\"C_STATUS\" TEXT," + // 8: cStatus
                "\"C_POSITION\" TEXT," + // 9: cPosition
                "\"USER_ID\" TEXT," + // 10: userId
                "\"LINE_ID\" INTEGER," + // 11: lineId
                "\"IS_FINSH_POINT\" TEXT," + // 12: isFinshPoint
                "\"R_ITEM_LAST_TIME\" TEXT," + // 13: rItemLastTime
                "\"INFO\" TEXT);"); // 14: info
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CHECK_PIONT\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, CheckPiont entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindLong(2, entity.getLBuilding());
 
        String cNo = entity.getCNo();
        if (cNo != null) {
            stmt.bindString(3, cNo);
        }
 
        Long lId = entity.getLId();
        if (lId != null) {
            stmt.bindLong(4, lId);
        }
 
        String cName = entity.getCName();
        if (cName != null) {
            stmt.bindString(5, cName);
        }
 
        String cDesc = entity.getCDesc();
        if (cDesc != null) {
            stmt.bindString(6, cDesc);
        }
 
        String cQrcode = entity.getCQrcode();
        if (cQrcode != null) {
            stmt.bindString(7, cQrcode);
        }
 
        String dCreate = entity.getDCreate();
        if (dCreate != null) {
            stmt.bindString(8, dCreate);
        }
 
        String cStatus = entity.getCStatus();
        if (cStatus != null) {
            stmt.bindString(9, cStatus);
        }
 
        String cPosition = entity.getCPosition();
        if (cPosition != null) {
            stmt.bindString(10, cPosition);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(11, userId);
        }
 
        Long lineId = entity.getLineId();
        if (lineId != null) {
            stmt.bindLong(12, lineId);
        }
 
        String isFinshPoint = entity.getIsFinshPoint();
        if (isFinshPoint != null) {
            stmt.bindString(13, isFinshPoint);
        }
 
        String rItemLastTime = entity.getRItemLastTime();
        if (rItemLastTime != null) {
            stmt.bindString(14, rItemLastTime);
        }
 
        List info = entity.getInfo();
        if (info != null) {
            stmt.bindString(15, infoConverter.convertToDatabaseValue(info));
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, CheckPiont entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindLong(2, entity.getLBuilding());
 
        String cNo = entity.getCNo();
        if (cNo != null) {
            stmt.bindString(3, cNo);
        }
 
        Long lId = entity.getLId();
        if (lId != null) {
            stmt.bindLong(4, lId);
        }
 
        String cName = entity.getCName();
        if (cName != null) {
            stmt.bindString(5, cName);
        }
 
        String cDesc = entity.getCDesc();
        if (cDesc != null) {
            stmt.bindString(6, cDesc);
        }
 
        String cQrcode = entity.getCQrcode();
        if (cQrcode != null) {
            stmt.bindString(7, cQrcode);
        }
 
        String dCreate = entity.getDCreate();
        if (dCreate != null) {
            stmt.bindString(8, dCreate);
        }
 
        String cStatus = entity.getCStatus();
        if (cStatus != null) {
            stmt.bindString(9, cStatus);
        }
 
        String cPosition = entity.getCPosition();
        if (cPosition != null) {
            stmt.bindString(10, cPosition);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(11, userId);
        }
 
        Long lineId = entity.getLineId();
        if (lineId != null) {
            stmt.bindLong(12, lineId);
        }
 
        String isFinshPoint = entity.getIsFinshPoint();
        if (isFinshPoint != null) {
            stmt.bindString(13, isFinshPoint);
        }
 
        String rItemLastTime = entity.getRItemLastTime();
        if (rItemLastTime != null) {
            stmt.bindString(14, rItemLastTime);
        }
 
        List info = entity.getInfo();
        if (info != null) {
            stmt.bindString(15, infoConverter.convertToDatabaseValue(info));
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public CheckPiont readEntity(Cursor cursor, int offset) {
        CheckPiont entity = new CheckPiont( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.getInt(offset + 1), // lBuilding
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // cNo
            cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // lId
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // cName
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cDesc
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cQrcode
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // dCreate
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // cStatus
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cPosition
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // userId
            cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11), // lineId
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // isFinshPoint
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // rItemLastTime
            cursor.isNull(offset + 14) ? null : infoConverter.convertToEntityProperty(cursor.getString(offset + 14)) // info
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, CheckPiont entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setLBuilding(cursor.getInt(offset + 1));
        entity.setCNo(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setLId(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3));
        entity.setCName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setCDesc(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setCQrcode(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDCreate(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setCStatus(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setCPosition(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setUserId(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setLineId(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
        entity.setIsFinshPoint(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setRItemLastTime(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setInfo(cursor.isNull(offset + 14) ? null : infoConverter.convertToEntityProperty(cursor.getString(offset + 14)));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(CheckPiont entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(CheckPiont entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(CheckPiont entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
